var url = urls();

//小剧场
var video_page = 1;

function video_list() {
    $.ajax({
        type: "post",
        url: url + "/api/statement/theatre",
        data: {
            number: 8,
            page: video_page
        },
        dataType: "json",
        success: function (res) {
            video_show(res);
        }
    });
}

function video_show(res) {
    var arr = res.data.data;
    var pageNum = Math.ceil(res.data.total / 8);
    var a = '';
    for (i in arr) {
        a += '<li> <div class="theatre_img_box"><a target = "video" href = ' + arr[i].url + '><img src="' + url +
            '/upload/' + arr[i]
            .image +                                                    
            '" class="theatre_img" /><div class="theatre_img_bg"><img src="'+url+'/themes/simpleboot3/public/assets/simpleboot3/yihe/images/video.png" class="video_img" /></div></a></div><p class="theatre_title">' +
            arr[i].title + '</p></li>';
    }
    $(".theatre_list").html(a);
    $(".theatre_page_bg").css("display", "none");
    $("#theatre_page").paging({
        nowPage: video_page, // 当前页码
        pageNum: pageNum, // 总页码
        buttonNum: 7, //要展示的页码数量
        callback: function (num) { //回调函数
            $(".theatre_page_bg").css("display", "block");
            video_page = num;
            video_list();
        }
    });

}
//律趣
var LV_QU_page = 1;

function LV_QU_list() {
    $.ajax({
        type: "post",
        url: url + "/api/statement/lv_qu",
        data: {
            number: 8,
            type: 2,
            page: LV_QU_page
        },
        dataType: "json",
        success: function (res) {
            LV_QU(res);
        }
    });
}

function LV_QU(res) {
    var arr = res.data.data;
    var pageNum = Math.ceil(res.data.total / 8);
    var a = '';
    for (i in arr) {
        a += '<li><div class="LV_QU_list_box" style="background: url(' + url + '/upload/' + arr[i].thumbnail +
            ') no-repeat;  background-size:100% 100%"><div class="LV_QU_list_bg"><div class="LV_QU_list_icon_box"><div class="LV_QU_list_icon"></div><p class="LV_QU_list_icon_title">查看大图</p></div><img class="LV_QU_list_img"src="' +
            url + '/upload/' + arr[i].thumbnail + '"data-original="' + url + '/upload/' + arr[i].image + '"alt="' +
            arr[i].title + '" /></div></div><p class="LV_QU_title">' + arr[i].title + '</p></li>';
    }
    $("#viewer").html(a);
    $('#viewer').viewer({
        url: 'data-original',
        // movable: false, //移动
        title: false, //标题
        // navbar: false,  //缩略图
        // transition: false,   //动画
    })
    $("#viewer").viewer('update');
    $(".LV_QU_page_bg").css("display", "none");
    $("#LV_QU_page").paging({
        nowPage: LV_QU_page, // 当前页码
        pageNum: pageNum, // 总页码
        buttonNum: 7, //要展示的页码数量
        callback: function (num) { //回调函数
            $(".LV_QU_page_bg").css("display", "block");
            LV_QU_page = num;
            LV_QU_list();
        }
    });
}

//热点话题
var hot_page = 1;

function hot_list() {
    $.ajax({
        type: "post",
        url: url + "/api/statement/hot",
        data: {
            number: 4,
            type: 2,
            page: hot_page
        },
        dataType: "json",
        success: function (res) {
            hot(res);
        }
    });
}

function hot(res) {
    var arr = res.data.data;
    var pageNum = Math.ceil(res.data.total / 4);
    var a = '';
    for (i in arr) {
        var time = timestampToTime(arr[i].update_time);
        a += '<li class="hot" id="topics_' + arr[i].id + '"><img src="' + url + '/upload/' + arr[i].thumbnail +
            '" class="topics_img" /><div class="topics_txt_box"><p class="topics_title">' + arr[i].post_title +
            '</p><p class="topics_txt">' + arr[i].post_excerpt + '</p><p class="topics_time">' + time +
            '</p></div></li>'
    }
    $(".topics_list").html(a);
    $(".hot").click(function () {
        window.location.href = url + "/portal/index/hot?id=" + this.id;
    })


    $(".topics_page_bg").css("display", "none");
    $("#topics_page").paging({
        nowPage: hot_page, // 当前页码
        pageNum: pageNum, // 总页码
        buttonNum: 7, //要展示的页码数量
        callback: function (num) { //回调函数
            $(".topics_page_bg").css("display", "block");
            hot_page = num;
            hot_list();
        }
    });
}

$(function () {
    //小剧场
    video_list();
    //律趣
    LV_QU_list();
    //热点话题
    hot_list();
})